// Copyright (c) 2002 Cunningham & Cunningham, Inc.
// Released under the terms of the GNU General Public License version 2 or later.

package fat
{

public class Money
{

    private var cents : Number;

    public function Money(s : String) {
        var stripped : String = "";
        for (var i : int = 0; i < s.length; i++) {
            var c : String = s.charAt(i);
            if (( c >= "0" && c <= "9" ) || c == '.') {
                stripped += c;
            }
        }
        cents = Math.floor(100 * parseFloat(stripped));
    }

    public function equals(value : Object) : Boolean {
        return (value is Money) && cents == Money(value).cents;
    }

    public function hashCode() : int {
        return int(cents);
    }

    public function toString() : String {
        return cents + " cents";
    }
}

}